home *** CD-ROM | disk | FTP | other *** search
- // CD Playthrough
- // Version: 1.5 <October 3, 1994>
- // (c) 1994 neg.active.productions, jwang@csua.berkeley.edu <James Wang>
- // ftp://ftp.csua.berkeley.edu/pub/jwang/cool/cd-playthrough-15.hqx
-
- // File: main.c
- //
- // Contains: C program to juggle sound input and output rate options
- //
- // Written by: James Wang
- //
- // Description: Includes main() dispatching routine, initialization and
- // miscellaneous utility routines.
-
-
- #include "main.h"
-
-
- void init_all(void)
- {
- InitGraf((Ptr) &qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- FlushEvents(everyEvent, 0);
- TEInit();
- InitDialogs(0L);
- InitCursor();
- }
-
- void stop_alert(short id)
- {
- Str255 errMessage;
- Str15 numMessage;
-
- GetIndString(errMessage, kErrMessageID, id);
- NumToString((long)id, numMessage);
-
- if (errMessage[0] == 0)
- ParamText("\pError message not found, program may be damaged!", numMessage, 0, 0);
- else
- ParamText(errMessage, numMessage, 0, 0);
-
- StopAlert(kStopAlertID, 0);
- ExitToShell();
- }
-
- void handle_res_error(short err)
- {
- if (err != noErr)
- {
- if ( (err >= wrPermErr) && (err <= dirFulErr) )
- stop_alert(DiskError);
- if (err == memFullErr)
- stop_alert(MemFull);
- stop_alert(ResError);
- }
- }
-
- Boolean is_pressed(unsigned short k)
- {
- unsigned char km[16];
-
- GetKeys((long *)km);
- return ((km[k>>3] >> (k & 7)) & 1);
- }
-
- void main(void)
- {
- SoundSetting mySnd;
-
- init_all();
-
- if (is_pressed(kcCtrl)) {
- get_sound_in(&mySnd);
- get_sound_out(&mySnd);
- save_prefs(&mySnd);
- return;
- }
-
- if (is_pressed(kcCmd))
- system_prefs(&mySnd);
- else
- read_prefs(&mySnd);
-
- set_sound_in(&mySnd);
- set_sound_out(&mySnd);
- }
-